#include "ftpsession.h"

FtpSession::FtpSession(qintptr socketHandle, const ServerConfig& serverConfig, QObject *parent) :
    QThread(parent),
    m_worker(new FtpSessionWorker(socketHandle, serverConfig))
{
    m_worker->moveToThread(this);

    connect(this, &FtpSession::started, m_worker, &FtpSessionWorker::init);
    connect(this, &FtpSession::finished, m_worker, &FtpSessionWorker::clean);
    connect(m_worker, &FtpSessionWorker::quit, this, &FtpSession::onQuit);
}

FtpSession::~FtpSession()
{
    delete m_worker;
}

void FtpSession::onQuit()
{
    quit();
    wait();
    deleteLater();
}
